home *** CD-ROM | disk | FTP | other *** search
/ ASME's Mechanical Engine…ing Toolkit 1997 December / ASME's Mechanical Engineering Toolkit 1997 December.iso / c_lang / tccurses.lzh / CURSESIO.ASM < prev    next >
Encoding:
Assembly Source File  |  1987-09-07  |  7.9 KB  |  291 lines

  1.     TITLE   PCcurses BIOS Control Functions for MicroSoft 'C' v.4.0
  2.     NAME    CURSESIO
  3.     PAGE    46,132
  4.     ;****************************************************************
  5.     ;*             CURSESIO.ASM                *
  6.     ;*                                *
  7.     ;* This file contains 'C' functions for the MicroSoft 'C' com-    *
  8.     ;* piler v.4.0. It exercises a number of BIOS video calls, and    *
  9.     ;* is intended for inclusion in a curses library package.    *
  10.     ;*                                *
  11.     ;* The two files FARNEAR.INC and SMALHUGE.INC each contain one    *
  12.     ;* EQUate. These define the module's memory model.        *
  13.     ;*                                *
  14.     ;****************************************************************
  15.     ;* This version of curses is based on ncurses, a curses version    * 
  16.     ;* originally written by Pavel Curtis at Cornell University.    *
  17.     ;* I have made substantial changes to make it run on IBM PC's,    *
  18.     ;* and therefore consider myself free to make it public domain.    *
  19.     ;*        Bjorn Larsson (...mcvax!enea!infovax!bl)    *
  20.     ;****************************************************************
  21.     ;* Author: Bjorn Larsson                    *
  22.     ;* Revised:                            *
  23.     ;* 1.0:    Release:                    870515    *
  24.     ;****************************************************************
  25.     ;
  26.     INCLUDE    FARNEAR.INC        ;DEFINE FAR OR NEAR CALL SEQUENCE
  27.     INCLUDE    SMALHUGE.INC        ;DEFINE FAR OR NEAR DATA ACCESS
  28.     ;
  29. SYSTEM    EQU    21H            ;SYSTEM CALL
  30. BRKCHK    EQU    33H            ;BREAK SET/CHECK FUNCTION CODE
  31.     ;
  32. _TEXT    SEGMENT  BYTE PUBLIC 'CODE'
  33.     ASSUME  CS: _TEXT
  34.     ;
  35.     ;****************************************************************
  36.     ;* Function entry and exit macros, and parameter fetch macro.    *
  37.     ;* Used by all functions.                    *
  38.     ;****************************************************************
  39.     ;
  40. c_entry    MACRO    f_name
  41.     ;
  42.     if far_call
  43. &f_name    proc far
  44.     else
  45. &f_name    proc near
  46.     endif
  47.     push    bp
  48.     mov    bp,sp
  49.     push    di
  50.     push    si
  51.     ;
  52.     ENDM
  53.     ;
  54. c_exit    MACRO    f_name
  55.     ;
  56.     pop    si
  57.     pop    di
  58.     pop    bp
  59.     ret
  60. &f_name    endp
  61.     ;
  62.     ENDM
  63.     ;
  64. g_parm    MACRO    reg,p_num
  65.     if    far_call
  66.     mov    ®,[bp+&p_num*2+4]
  67.     else
  68.     mov    ®,[bp+&p_num*2+2]
  69.     endif
  70.     ;
  71.     ENDM
  72.     ;
  73.     PAGE
  74.     ;****************************************************************
  75.     ;*            _cursesocattr                *
  76.     ;*                                *
  77.     ;* void _cursescattr(chr,attr)                    *
  78.     ;*                                *
  79.     ;* Writes char 'chr' with attributes 'attr' to the current cur-    *
  80.     ;* sor location.                        *
  81.     ;****************************************************************
  82.     PUBLIC    __cursescattr
  83.     ;
  84.     c_entry __cursescattr
  85.     MOV    AH,9
  86.     MOV    BH,0        ;USE PAGE 0
  87.     g_parm    AL,2        ;GET CHR PARAMETER
  88.     g_parm    BL,3        ;GET ATTR PARAMETER
  89.     MOV    CX,1        ;PUT 1 CHARACTER
  90.     INT    10H
  91.     c_exit    __cursescattr
  92.     ;
  93.     ;****************************************************************
  94.     ;*            _cursescursor                *
  95.     ;*                                *
  96.     ;* void _cursescursor(row,column)                *
  97.     ;*                                *
  98.     ;* Sets the cursor position in video page 0. 'row' and 'column'    *
  99.     ;* are the cursor address. If 'row' is set to 25, no cursor at    *
  100.     ;* all is displayed.                        *
  101.     ;****************************************************************
  102.     PUBLIC    __cursescursor
  103.     ;
  104.     c_entry __cursescursor
  105.     MOV    AH,2
  106.     MOV    BH,0        ;USE PAGE 0
  107.     g_parm    DH,2        ;GET ROW PARAMETER
  108.     g_parm    DL,3        ;GET COLUMN PARAMETER
  109.     INT    10H
  110.     c_exit    __cursescursor
  111.     ;
  112.     ;****************************************************************
  113.     ;*            _cursesgcols                *
  114.     ;*                                *
  115.     ;* int _cursesgcols()                        *
  116.     ;*                                *
  117.     ;* Return the current number of columns on the screen.        *
  118.     ;****************************************************************
  119.     PUBLIC    __cursesgcols
  120.     ;
  121.     c_entry    __cursesgcols
  122.     MOV    AH,15
  123.     INT    10H
  124.     MOV    AL,AH
  125.     XOR    AH,AH
  126.     c_exit    __cursesgcols
  127.     ;
  128.     ;****************************************************************
  129.     ;*            _cursesputc                *
  130.     ;*                                *
  131.     ;* void _cursesputc(chr,colour)                    *
  132.     ;*                                *
  133.     ;* Output character 'chr' to screen in tty fashion. If a colour    *
  134.     ;* mode is active, the character is written with colour        *
  135.     ;* 'colour'.                            *
  136.     ;****************************************************************
  137.     PUBLIC    __cursesputc
  138.     ;
  139.     c_entry    __cursesputc
  140.     MOV    AH,14
  141.     g_parm    AL,1        ;GET CHR PARAMETER
  142.     g_parm    BL,2        ;GET COLOUR PARAMETER
  143.     INT    10H
  144.     c_exit    __cursesputc
  145.     ;
  146.     ;****************************************************************
  147.     ;*            _cursesscroll                *
  148.     ;*                                *
  149.     ;* void _cursesscroll(urow,lcol,lrow,rcol,lines,attr)        *
  150.     ;*                                *
  151.     ;* Scroll a window in the current page up or down. Urow, lcol,    *
  152.     ;* lrow,rcol are the window coordinats. lines is the number of    *
  153.     ;* lines to scroll. If 0, clears the window, if < 0 scrolls    *
  154.     ;* down, > 0 scrolls up. Blanks areas that are left, and sets    *
  155.     ;* character attributes to attr. If in a colour graphics mode,    *
  156.     ;* fills them with the colour 'attr' instead.            *
  157.     ;****************************************************************
  158.     PUBLIC    __cursesscroll
  159.     ;
  160.     c_entry    __cursesscroll
  161.     g_parm    AL,5        ;GET LINES PARAMETER
  162.     MOV    AH,6
  163.     TEST    AL,80H
  164.     JZ    SHORT CS_1
  165.     ;
  166.     MOV    AH,7
  167.     NEG    AL
  168.     ;
  169. CS_1:    g_parm    CH,1        ;GET UROW PARAMETER
  170.     g_parm    CL,2        ;GET LCOL PARAMETER
  171.     g_parm    DH,3        ;GET LROW PARAMETER
  172.     g_parm    DL,4        ;GET RCOL PARAMETER
  173.     g_parm    BH,6        ;GET ATTR PARAMETER
  174.     INT    10H
  175.     c_exit    __cursesscroll
  176.     ;
  177.     ;****************************************************************
  178.     ;*            _cursesgcmode                *
  179.     ;*                                *
  180.     ;* int _cursesgcmode()                        *
  181.     ;*                                *
  182.     ;* Return the current cursor type. Bits 8-15 of the return    *
  183.     ;* value is the start scan row, and bits 0-7 is the end scan    *
  184.     ;* row.                                *
  185.     ;****************************************************************
  186.     PUBLIC    __cursesgcmode
  187.     ;
  188.     c_entry    __cursesgcmode
  189.     MOV    AH,3
  190.     INT    10H
  191.     MOV    AX,CX
  192.     c_exit    __cursesgcmode
  193.     ;
  194.     ;****************************************************************
  195.     ;*            _cursescmode                *
  196.     ;*                                *
  197.     ;* void _cursescmode(startrow,endrow)                *
  198.     ;*                                *
  199.     ;* Sets the cursor type to begin in scan line startrow and end    *
  200.     ;* in scan line endrow. Both values should be 0-31.        *
  201.     ;****************************************************************
  202.     PUBLIC    __cursescmode
  203.     ;
  204.     c_entry __cursescmode
  205.     MOV    AH,1
  206.     g_parm    CH,1        ;GET STARTROW PARAMETER
  207.     g_parm    CL,2        ;GET ENDROW PARAMETER
  208.     INT    10H
  209.     c_exit    __cursescmode
  210.     ;
  211.     ;****************************************************************
  212.     ;*             _curseskey                *
  213.     ;*                                *
  214.     ;* int _curseskey()                        *
  215.     ;*                                *
  216.     ;* Returns the next key code struck at the keyboard. If the low    *
  217.     ;* 8 bits are non-0, the uper bits contain the extended cha-    *
  218.     ;* racter code. If bit 0-7 are non-zero, the upper bits = 0.    *
  219.     ;****************************************************************
  220.     PUBLIC    __curseskey
  221.     ;
  222.     c_entry __curseskey
  223.     MOV    AH,0
  224.     INT    16H
  225.     CMP    AL,0
  226.     JZ    SHORT EXTKEY
  227.     AND    AX,0FFH
  228. EXTKEY:
  229.     c_exit    __curseskey
  230.     ;
  231.     ;****************************************************************
  232.     ;*            _curseskeytst                *
  233.     ;*                                *
  234.     ;* int _curseskeytst()                        *
  235.     ;*                                *
  236.     ;* Returns 1 if a character is available, 0 otherwise.        *
  237.     ;****************************************************************
  238.     PUBLIC    __curseskeytst
  239.     ;
  240.     c_entry __curseskeytst
  241.     MOV    AH,1
  242.     INT    16H
  243.     JZ    SHORT TST1
  244.     MOV    AX,0
  245.     JMP    SHORT EXTTST
  246. TST1:    MOV    AX,1
  247. EXTTST:
  248.     c_exit    __curseskeytst
  249.     ;
  250.     ;****************************************************************
  251.     ;*            _cursesgcb                *
  252.     ;*                                *
  253.     ;* int _cursesgcb()                        *
  254.     ;*                                *
  255.     ;* Returns 1 if MSDOS BREAK CHECK is on, otherwise 0.        *
  256.     ;****************************************************************
  257.     PUBLIC    __cursesgcb
  258.     ;
  259.     c_entry __cursesgcb
  260.     MOV    AX,BRKCHK*256+0
  261.     INT    SYSTEM
  262.     XOR    AH,AH
  263.     MOV    AL,DL
  264.     c_exit    __cursesgcb
  265.     ;
  266.     ;****************************************************************
  267.     ;*            _cursesscb                *
  268.     ;*                                *
  269.     ;* void _cursesscb(setting)                    *
  270.     ;*                                *
  271.     ;* Sets MSDOS BREAK CHECK according to 'setting'.        *
  272.     ;****************************************************************
  273.     PUBLIC    __cursesscb
  274.     ;
  275.     c_entry __cursesscb
  276.     MOV    AX,BRKCHK*256+1
  277.     g_parm    DL,1
  278.     AND    DL,DL
  279.     JZ    SHORT SCB1
  280.     MOV    DL,1
  281. SCB1:    INT    SYSTEM
  282.     c_exit    __cursesscb
  283.     ;
  284. _TEXT    ENDS
  285.     if1
  286.     %OUT    Pass 1 Completed
  287.     else
  288.     %OUT    Assembly Completed
  289.     endif
  290.     END
  291.